import { FormConfig } from "@/components";
import { Row } from "@/components/FTable/components/search";
import { configCurryFilter } from "@/dictionaries/filter";
import { isTrue } from "@/utils/tools";
import dayjs from "dayjs";
import { shallowRef } from "vue";
export const rows: Array<Row> = [
    {
        title: '名称',
        key: 'name',
        component: 'a-input',
    },
    {
        title: '是否上架',
        key: 'status',
        component: shallowRef(FormConfig),
        props: {
            prop: 'status',
        },
    },
]
export const columns: F.TableColumns[] = [
    {
        title: '名称',
        key: 'name',
        dataIndex: 'name',
        align: 'center',
        width: 200
    },
    {
        title: '封面',
        key: 'url',
        dataIndex: 'url',
        align: 'center',
        width: 200,
        customRender: ({ record }: F.RableSlotScope<defs.server.MovieEntity>) =>
            isTrue(record.cover) ? (
                <a-image width={50} src={record.cover} />
            ) : '-',
    },
    {
        title: '当前集数',
        key: 'episodeNumber',
        dataIndex: 'episodeNumber',
        align: 'center',
        width: 200
    },
    {
        title: '是否上架',
        key: 'status',
        dataIndex: 'status',
        align: 'center',
        customRender: configCurryFilter('status'),
    },
    {
        title: '是否免费',
        key: 'free',
        dataIndex: 'free',
        align: 'center',
        width: 120,
        customRender: configCurryFilter('freeType'),
    },
    {
        title: '购买金额',
        key: 'amount',
        dataIndex: 'amount',
        align: 'center',
        width: 120
    },
    {
        title: '播放量',
        key: 'playCount',
        dataIndex: 'playCount',
        align: 'center',
        width: 120,
    },
    {
        title: '点赞数',
        key: 'likeCount',
        dataIndex: 'likeCount',
        align: 'center',
        width: 120,
    },
    {
        title: '收藏量',
        key: 'collectCount',
        dataIndex: 'collectCount',
        align: 'center',
        width: 150,
    },
    {
        title: '创建时间',
        key: 'createDate',
        dataIndex: 'createDate',
        align: 'center',
        width: 180,
        customRender: ({ record }: F.RableSlotScope<defs.server.MoviesEpisodeEntity>) =>
            record.createDate && dayjs(record.createDate).format('YYYY-MM-DD HH:mm:ss'),
    },
    {
        title: '更新时间',
        key: 'updateDate',
        dataIndex: 'updateDate',
        align: 'center',
        width: 180,
        customRender: ({ record }: F.RableSlotScope<defs.server.MoviesEpisodeEntity>) =>
            record.updateDate && dayjs(record.updateDate).format('YYYY-MM-DD HH:mm:ss'),
    },
    {
        title: '操作',
        dataIndex: 'action',
        key: 'action',
        align: 'center',
        slots: {
            customRender: 'actionRender',
        },
        width: 200,
        fixed: 'right',
    },
]